home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / dodge.swf / scripts / __Packages / LevelManager.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  12.6 KB  |  386 lines

  1. class LevelManager extends MovieClip
  2. {
  3.    static var wm;
  4.    static var title;
  5.    static var displayBox;
  6.    static var level = 0;
  7.    static var pausable = false;
  8.    function LevelManager()
  9.    {
  10.       super();
  11.       LevelManager.signal();
  12.    }
  13.    static function addStuffTest()
  14.    {
  15.       LevelManager.wm = new WaveManager(210,360);
  16.       var _loc1_ = 0;
  17.       while(_loc1_ < 3 * LevelManager.level)
  18.       {
  19.          LevelManager.wm.push("Enemy");
  20.          _loc1_ = _loc1_ + 1;
  21.       }
  22.       _loc1_ = 0;
  23.       while(_loc1_ < 2 * LevelManager.level - 2)
  24.       {
  25.          LevelManager.wm.push("MovingEnemy");
  26.          _loc1_ = _loc1_ + 1;
  27.       }
  28.       _loc1_ = 0;
  29.       while(_loc1_ < 1.5 * LevelManager.level - 3)
  30.       {
  31.          LevelManager.wm.push("SelfDestructingEnemy");
  32.          _loc1_ = _loc1_ + 1;
  33.       }
  34.       _loc1_ = 0;
  35.       while(_loc1_ < 0.5 * LevelManager.level - 1.5)
  36.       {
  37.          LevelManager.wm.push("TeleportingEnemy");
  38.          _loc1_ = _loc1_ + 1;
  39.       }
  40.       _loc1_ = 0;
  41.       while(_loc1_ < 0.5 * LevelManager.level - 2)
  42.       {
  43.          LevelManager.wm.push("StraightEnemy");
  44.          _loc1_ = _loc1_ + 1;
  45.       }
  46.    }
  47.    static function populateWave()
  48.    {
  49.       switch(LevelManager.level)
  50.       {
  51.          case 1:
  52.             LevelManager.title = "Getting your feet wet";
  53.             LevelManager.wm = new WaveManager(60,120,1);
  54.             var _loc1_ = 0;
  55.             while(_loc1_ < 6)
  56.             {
  57.                LevelManager.wm.push("Enemy");
  58.                _loc1_ = _loc1_ + 1;
  59.             }
  60.             break;
  61.          case 2:
  62.             LevelManager.title = "Here they come!";
  63.             LevelManager.wm = new WaveManager(90,150,2);
  64.             _loc1_ = 0;
  65.             while(_loc1_ < 12)
  66.             {
  67.                LevelManager.wm.push("Enemy");
  68.                _loc1_ = _loc1_ + 1;
  69.             }
  70.             break;
  71.          case 3:
  72.             LevelManager.title = "New and improved!";
  73.             LevelManager.wm = new WaveManager(60,120,1);
  74.             _loc1_ = 0;
  75.             while(_loc1_ < 6)
  76.             {
  77.                LevelManager.wm.push("Enemy");
  78.                _loc1_ = _loc1_ + 1;
  79.             }
  80.             LevelManager.wm.push("MovingEnemy");
  81.             LevelManager.wm.push("MovingEnemy");
  82.             break;
  83.          case 4:
  84.             LevelManager.title = "Medley";
  85.             LevelManager.wm = new WaveManager(90,150,2);
  86.             _loc1_ = 0;
  87.             while(_loc1_ < 6)
  88.             {
  89.                LevelManager.wm.push("Enemy");
  90.                LevelManager.wm.push("MovingEnemy");
  91.                _loc1_ = _loc1_ + 1;
  92.             }
  93.             break;
  94.          case 5:
  95.             LevelManager.title = "Restless";
  96.             LevelManager.wm = new WaveManager(60,90,1);
  97.             _loc1_ = 0;
  98.             while(_loc1_ < 8)
  99.             {
  100.                LevelManager.wm.push("MovingEnemy");
  101.                _loc1_ = _loc1_ + 1;
  102.             }
  103.             break;
  104.          case 6:
  105.             LevelManager.title = "Suicidal";
  106.             LevelManager.wm = new WaveManager(60,90,1);
  107.             _loc1_ = 0;
  108.             while(_loc1_ < 6)
  109.             {
  110.                LevelManager.wm.push("Enemy");
  111.                LevelManager.wm.push("MovingEnemy");
  112.                _loc1_ = _loc1_ + 1;
  113.             }
  114.             _loc1_ = 0;
  115.             while(_loc1_ < 3)
  116.             {
  117.                LevelManager.wm.push("SelfDestructingEnemy");
  118.                _loc1_ = _loc1_ + 1;
  119.             }
  120.             break;
  121.          case 7:
  122.             LevelManager.title = "Escalation";
  123.             LevelManager.wm = new WaveManager(90,150,2);
  124.             _loc1_ = 0;
  125.             while(_loc1_ < 8)
  126.             {
  127.                LevelManager.wm.push("Enemy");
  128.                LevelManager.wm.push("MovingEnemy");
  129.                LevelManager.wm.push("SelfDestructingEnemy");
  130.                _loc1_ = _loc1_ + 1;
  131.             }
  132.             break;
  133.          case 8:
  134.             LevelManager.title = "They come in threes";
  135.             LevelManager.wm = new WaveManager(120,180,3);
  136.             _loc1_ = 0;
  137.             while(_loc1_ < 10)
  138.             {
  139.                LevelManager.wm.push("Enemy");
  140.                LevelManager.wm.push("MovingEnemy");
  141.                LevelManager.wm.push("SelfDestructingEnemy");
  142.                _loc1_ = _loc1_ + 1;
  143.             }
  144.             break;
  145.          case 9:
  146.             LevelManager.title = "Just dodge";
  147.             LevelManager.wm = new WaveManager(420,420,4);
  148.             _loc1_ = 0;
  149.             while(_loc1_ < 12)
  150.             {
  151.                LevelManager.wm.push("SelfDestructingEnemy");
  152.                _loc1_ = _loc1_ + 1;
  153.             }
  154.             break;
  155.          case 10:
  156.             LevelManager.title = "Huh?";
  157.             LevelManager.wm = new WaveManager(90,150,2);
  158.             _loc1_ = 0;
  159.             while(_loc1_ < 6)
  160.             {
  161.                LevelManager.wm.push("Enemy");
  162.                LevelManager.wm.push("MovingEnemy");
  163.                LevelManager.wm.push("SelfDestructingEnemy");
  164.                _loc1_ = _loc1_ + 1;
  165.             }
  166.             _loc1_ = 0;
  167.             while(_loc1_ < 3)
  168.             {
  169.                LevelManager.wm.push("TeleportingEnemy");
  170.                LevelManager.wm.push("SelfDestructingEnemy");
  171.                _loc1_ = _loc1_ + 1;
  172.             }
  173.             break;
  174.          case 11:
  175.             LevelManager.title = "Medley II";
  176.             LevelManager.wm = new WaveManager(120,180,3);
  177.             _loc1_ = 0;
  178.             while(_loc1_ < 12)
  179.             {
  180.                LevelManager.wm.push("Enemy");
  181.                LevelManager.wm.push("MovingEnemy");
  182.                LevelManager.wm.push("SelfDestructingEnemy");
  183.                LevelManager.wm.push("TeleportingEnemy");
  184.                _loc1_ = _loc1_ + 1;
  185.             }
  186.             break;
  187.          case 12:
  188.             LevelManager.title = "Green mayhem";
  189.             LevelManager.wm = new WaveManager(90,150,2);
  190.             _loc1_ = 0;
  191.             while(_loc1_ < 12)
  192.             {
  193.                LevelManager.wm.push("TeleportingEnemy");
  194.                LevelManager.wm.push("SelfDestructingEnemy");
  195.                _loc1_ = _loc1_ + 1;
  196.             }
  197.             break;
  198.          case 13:
  199.             LevelManager.title = "Lucky thirteen";
  200.             LevelManager.wm = new WaveManager(60,90,13);
  201.             _loc1_ = 0;
  202.             while(_loc1_ < 4)
  203.             {
  204.                LevelManager.wm.push("Enemy");
  205.                LevelManager.wm.push("MovingEnemy");
  206.                LevelManager.wm.push("SelfDestructingEnemy");
  207.                LevelManager.wm.push("TeleportingEnemy");
  208.                _loc1_ = _loc1_ + 1;
  209.             }
  210.             LevelManager.wm.push("Enemy");
  211.             break;
  212.          case 14:
  213.             LevelManager.title = "Four of \'em";
  214.             LevelManager.wm = new WaveManager(150,210,4);
  215.             _loc1_ = 0;
  216.             while(_loc1_ < 20)
  217.             {
  218.                LevelManager.wm.push("Enemy");
  219.                LevelManager.wm.push("MovingEnemy");
  220.                LevelManager.wm.push("SelfDestructingEnemy");
  221.                LevelManager.wm.push("TeleportingEnemy");
  222.                _loc1_ = _loc1_ + 1;
  223.             }
  224.             break;
  225.          case 15:
  226.             LevelManager.title = "Don\'t blink!";
  227.             LevelManager.wm = new WaveManager(60,90,2);
  228.             _loc1_ = 0;
  229.             while(_loc1_ < 50)
  230.             {
  231.                LevelManager.wm.push("TeleportingEnemy");
  232.                _loc1_ = _loc1_ + 1;
  233.             }
  234.             break;
  235.          case 16:
  236.             LevelManager.title = "Snipers";
  237.             LevelManager.wm = new WaveManager(90,150,2);
  238.             _loc1_ = 0;
  239.             while(_loc1_ < 6)
  240.             {
  241.                LevelManager.wm.push("Enemy");
  242.                LevelManager.wm.push("MovingEnemy");
  243.                LevelManager.wm.push("SelfDestructingEnemy");
  244.                LevelManager.wm.push("TeleportingEnemy");
  245.                _loc1_ = _loc1_ + 1;
  246.             }
  247.             _loc1_ = 0;
  248.             while(_loc1_ < 3)
  249.             {
  250.                LevelManager.wm.push("StraightEnemy");
  251.                _loc1_ = _loc1_ + 1;
  252.             }
  253.             break;
  254.          case 17:
  255.             LevelManager.title = "Medley III";
  256.             LevelManager.wm = new WaveManager(120,180,3);
  257.             _loc1_ = 0;
  258.             while(_loc1_ < 12)
  259.             {
  260.                LevelManager.wm.push("Enemy");
  261.                LevelManager.wm.push("MovingEnemy");
  262.                LevelManager.wm.push("SelfDestructingEnemy");
  263.                LevelManager.wm.push("TeleportingEnemy");
  264.                LevelManager.wm.push("StraightEnemy");
  265.                _loc1_ = _loc1_ + 1;
  266.             }
  267.             _loc1_ = 0;
  268.             while(_loc1_ < 3)
  269.             {
  270.                LevelManager.wm.push("SelfDestructingEnemy");
  271.                _loc1_ = _loc1_ + 1;
  272.             }
  273.             break;
  274.          case 18:
  275.             LevelManager.title = "Citrus";
  276.             LevelManager.wm = new WaveManager(90,150,2);
  277.             _loc1_ = 0;
  278.             while(_loc1_ < 15)
  279.             {
  280.                LevelManager.wm.push("StraightEnemy");
  281.                _loc1_ = _loc1_ + 1;
  282.             }
  283.             break;
  284.          case 19:
  285.             LevelManager.title = "Last stand";
  286.             LevelManager.wm = new WaveManager(150,240,5);
  287.             _loc1_ = 0;
  288.             while(_loc1_ < 20)
  289.             {
  290.                LevelManager.wm.push("Enemy");
  291.                LevelManager.wm.push("MovingEnemy");
  292.                LevelManager.wm.push("SelfDestructingEnemy");
  293.                LevelManager.wm.push("TeleportingEnemy");
  294.                LevelManager.wm.push("StraightEnemy");
  295.                _loc1_ = _loc1_ + 1;
  296.             }
  297.             break;
  298.          case 20:
  299.             LevelManager.title = "Back to the beginning";
  300.             LevelManager.wm = new FinaleWaveManager();
  301.       }
  302.    }
  303.    static function resetPlayer()
  304.    {
  305.       _root.player.getMovie()._x = Stage.width >> 1;
  306.       _root.player.getMovie()._y = Stage.height >> 1;
  307.       _root.player.getMovie()._rotation = 0;
  308.    }
  309.    static function start()
  310.    {
  311.       LevelManager.pausable = true;
  312.       LevelManager.displayBox.removeMovieClip();
  313.       _root.debrisField.dimField();
  314.       Stepper.unpause();
  315.    }
  316.    static function signal()
  317.    {
  318.       LevelManager.pausable = false;
  319.       _root.kongregateStats.submit("MaxLevel",LevelManager.level);
  320.       LevelManager.level = LevelManager.level + 1;
  321.       LevelManager.wm.die();
  322.       LevelManager.populateWave();
  323.       Stepper.pause();
  324.       LevelManager.resetPlayer();
  325.       LevelManager.display("Level " + LevelManager.level + ": " + LevelManager.title);
  326.    }
  327.    static function signalFinished()
  328.    {
  329.       _root.kongregateStats.submit("GameComplete",1);
  330.       ScoreManager.addScore(ScoreManager.getScore() * 0.1);
  331.       LevelManager.restart();
  332.       LevelManager.displayScore("Congratulations! You win!");
  333.    }
  334.    static function signalDeath()
  335.    {
  336.       LevelManager.restart();
  337.       LevelManager.displayScore("You died!");
  338.    }
  339.    static function restart()
  340.    {
  341.       _root.kongregateStats.submit("Score",ScoreManager.getScore());
  342.       LevelManager.pausable = false;
  343.       LevelManager.level = 0;
  344.       LevelManager.wm.die();
  345.       LevelManager.wm = null;
  346.       var _loc3_ = 0;
  347.       while(_loc3_ < 10)
  348.       {
  349.          var _loc2_ = 0;
  350.          while(_loc2_ < Enemy.enemies.size())
  351.          {
  352.             Enemy.enemies["get"](_loc2_).die();
  353.             _loc2_ = _loc2_ + 1;
  354.          }
  355.          _loc2_ = 0;
  356.          while(_loc2_ < Missile.missiles.size())
  357.          {
  358.             Missile.missiles["get"](_loc2_).die();
  359.             _loc2_ = _loc2_ + 1;
  360.          }
  361.          _loc3_ = _loc3_ + 1;
  362.       }
  363.       _root.player.die();
  364.       _root.hm = new HudManager();
  365.    }
  366.    static function display(msg)
  367.    {
  368.       LevelManager.displayBox = _root.attachMovie("levelDisplayBox","levelDisplayBox" + _root.getNextHighestDepth(),_root.getNextHighestDepth());
  369.       LevelManager.displayBox._x = Stage.width >> 1;
  370.       LevelManager.displayBox._y = Stage.height >> 1;
  371.       LevelManager.displayBox.lvlText = msg;
  372.    }
  373.    static function displayScore(msg)
  374.    {
  375.       LevelManager.displayBox = _root.attachMovie("scoreDisplayBox","scoreDisplayBox" + _root.getNextHighestDepth(),_root.getNextHighestDepth());
  376.       LevelManager.displayBox._x = Stage.width >> 1;
  377.       LevelManager.displayBox._y = Stage.height >> 1;
  378.       LevelManager.displayBox.score = "Score: " + ScoreManager.getScore();
  379.       LevelManager.displayBox.lvlText = msg;
  380.    }
  381.    static function isPausable()
  382.    {
  383.       return LevelManager.pausable;
  384.    }
  385. }
  386.